package fr.paulmasson.jfreex.replay;

import java.net.URL;

import javax.swing.ImageIcon;

import fr.paulmasson.jfreex.Channel;

public class ReplayChannel implements Channel, Comparable<ReplayChannel> {

	private int id;
	private String url;
	private String title;
	

	public ReplayChannel(int id, String title, String url) {
		this.id = id;
		this.title = title;
		this.url = url;
	}
	
	@Override
	public String getIconName() {
		return this.title.replace(" ", "").toLowerCase() + "replay.png";
	}

	@Override
	public ImageIcon getIcon() {
		return null;
	}

	@Override
	public String getTitle() {
		return this.title;
	}

	@Override
	public void setTitle(String title) {
		this.title = title;
	}

	@Override
	public String getUrl() {
		return url;
	}

	@Override
	public Integer getId() {
		return id;
	}

	@Override
	public int compareTo(ReplayChannel o) {
		return new Integer(this.getId()).compareTo(o.getId());
	}
	
	public String toString() {
		return this.title;
	}

	@Override
	public String getIconPath() {
		URL url = this.getClass().getResource("/data/"+getIconName());
		if (url != null) {
			return url.toString().replace("file:","");
		} else {
			return this.getClass().getResource("/data/blank.png").toString().replace("file:","");
		}
	}

}
